package jsqlite;

import java.util.Vector;

/* loaded from: classes2.dex */
public class TableResult implements Callback {
    public boolean atmaxrows;
    public String[] column;
    public int maxrows;
    public int ncolumns;
    public int nrows;
    public Vector rows;
    public String[] types;

    public TableResult() {
        this.maxrows = 0;
        clear();
    }

    public TableResult(int i) {
        this.maxrows = 0;
        this.maxrows = i;
        clear();
    }

    public void clear() {
        this.column = new String[0];
        this.types = null;
        this.rows = new Vector();
        this.nrows = 0;
        this.ncolumns = 0;
        this.atmaxrows = false;
    }

    @Override // jsqlite.Callback
    public void columns(String[] strArr) {
        this.column = strArr;
        this.ncolumns = strArr.length;
    }

    @Override // jsqlite.Callback
    public void types(String[] strArr) {
        this.types = strArr;
    }

    @Override // jsqlite.Callback
    public boolean newrow(String[] strArr) {
        if (strArr != null) {
            int i = this.maxrows;
            if (i > 0 && this.nrows >= i) {
                this.atmaxrows = true;
                return true;
            }
            this.rows.addElement(strArr);
            this.nrows++;
            return false;
        }
        return false;
    }

    public String toString() {
        StringBuffer stringBuffer = new StringBuffer();
        int i = 0;
        while (true) {
            String str = "NULL";
            if (i >= this.ncolumns) {
                break;
            }
            String[] strArr = this.column;
            if (strArr[i] != null) {
                str = strArr[i];
            }
            stringBuffer.append(str);
            stringBuffer.append('|');
            i++;
        }
        stringBuffer.append('\n');
        for (int i2 = 0; i2 < this.nrows; i2++) {
            String[] strArr2 = (String[]) this.rows.elementAt(i2);
            for (int i3 = 0; i3 < this.ncolumns; i3++) {
                stringBuffer.append(strArr2[i3] == null ? "NULL" : strArr2[i3]);
                stringBuffer.append('|');
            }
            stringBuffer.append('\n');
        }
        return stringBuffer.toString();
    }
}
